﻿class Time
{
    public uint Hours { get; set; }
    public uint Minutes { get; set; }

    public Time(uint hours, uint minutes)
    {
        this.Hours = (hours % 24 + minutes / 60) % 24;
        this.Minutes = minutes % 60;
    }

    public Time()
        : this(0, 0) { }

    public override string ToString()
    {
        return string.Format("{0:00}:{1:00}", this.Hours, this.Minutes);
    }

    public static Time operator +(Time t, int minutes)
    {
        if (minutes < 0)
        {
            return t - (-minutes);
        }
        Time result = new Time(t.Hours, t.Minutes + (uint)minutes);
        return result;
    }

    public static Time operator -(Time t, int minutes)
    {
        if (minutes < 0)
        {
            return t + (-minutes);
        }
        int newHours =(int) t.Hours;
        int newMinutes =(int) t.Minutes;
        while (newMinutes<minutes)
        {
            newMinutes += 60;
            newHours--;
        }
        newMinutes -= (int)minutes;
        while (newHours < 0)
        {
            newHours += 24;
        }
        Time result = new Time((uint)newHours ,(uint)newMinutes);
        return result;
    }

    public static Time operator ++(Time t)
    {
        return t + 1;
    }

    public static Time operator --(Time t)
    {
        return t - 1;
    }
}

